package com.article.controller;

import com.article.entity.ApiResult;
import com.article.entity.model.ArticleCategory;
import com.article.service.ArticleCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "文章分类相关接口")
@RequestMapping("/articleCategory")
public class ArticleCategoryController {

    @Autowired
    private ArticleCategoryService articleCategoryService;

    @ApiOperation(value = "添加文章分类", notes = "添加文章分类")
    @RequestMapping(value = "/addArticleCategory")
    public ApiResult addArticleCategory(@RequestBody ArticleCategory param){
        ApiResult apiResult =  articleCategoryService.addArticleCategory(param);
        return ApiResult.ok();
    }

    @ApiOperation(value = "删除文章分类(主键)", notes = "删除文章分类(主键)")
    @RequestMapping(value = "/deleteArticleCategoryById")
    public ApiResult deleteArticleCategoryById(@RequestBody ArticleCategory param){
        ApiResult apiResult = articleCategoryService.deleteArticleCategoryById(param);
        return apiResult;
    }

    @ApiOperation(value = "删除文章分类递归(主键)", notes = "删除文章分类递归(主键)")
    @RequestMapping(value = "/deleteArticleCategoryRecursionById")
    public ApiResult deleteArticleCategoryRecursionById(@RequestBody ArticleCategory param){
        ApiResult apiResult = articleCategoryService.deleteArticleCategoryRecursiveById(param);
        return apiResult;
    }

    @ApiOperation(value = "更新文章分类(主键)",notes = "更新文章分类(主键)")
    @RequestMapping(value = "/updateArticleCategoryById")
    public ApiResult updateArticleCategoryById(@RequestBody ArticleCategory param){
        ApiResult apiResult = articleCategoryService.updateArticleCategoryById(param);
        return apiResult;
    }

    @ApiOperation(value = "查询文章分类递归", notes = "查询文章分类递归")
    @RequestMapping(value = "/selectArticleCategoryRecursionList")
    public ApiResult selectArticleCategoryRecursiveList(@RequestBody ArticleCategory param){
        ApiResult apiResult = articleCategoryService.selectArticleCategoryRecursiveList(param);
        return apiResult;
    }
}
